﻿@{
    Book Bk = ViewBag.Item;
    Layout = "~/Views/Shared/_SubLayout.cshtml";
    ViewBag.Title = "Item Detail";

    string sImageFile = string.Empty;
    if (File.Exists(Server.MapPath(string.Format("~/Content/Images/Book/{0}.jpg", Bk.BookCode))))
    {
        sImageFile = Bk.BookCode;
    }
    else
    {
        sImageFile = "nophoto";
    }
}
@*Script to restrict input characters in QTY textbox*@
<script type="text/javascript">

    $(document).ready(function () {
        $("#Qty").keydown(function (event) {
            // Allow: backspace, delete, tab and escape
            if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 ||
            // Allow: Ctrl+A
            (event.keyCode == 65 && event.ctrlKey === true) ||
            // Allow: home, end, left, right
            (event.keyCode >= 35 && event.keyCode <= 39)) {
                // let it happen, don't do anything
                return;
            }
            else {
                // Ensure that it is a number and stop the keypress
                if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105)) {
                    event.preventDefault();
                }
            }
        });
    });
</script>
@*Script to Validate Qty Field*@
<script type="text/javascript">

    //Our validation script will go here.
    $(document).ready(function () {
        //custom validation rule - checkQty
        $.validator.addMethod("checkQty",
       function (value, element) {
           var q = $('#Qty').val();
           if (q < 1) {
               return false;
           }
           else {
               return true;
           }

       });

        //validation implementation will go here.
        $('form').validate({
            rules: {
                Qty: {
                    required: true,
                    checkQty: true
                }
            },
            messages: {
                Qty: {
                    required: "Qty is required.",
                    checkQty: "Qty should be greater then ZERO(0)"
                }
            },
            errorElement: "div"
        });
    })

</script>
<div class="crumb_nav">
    <a href="@Url.Action("Index")" >home</a> &gt;&gt; @Bk.BookName
</div>
<div class="title">
    <span class="title_icon">
        <img src="@Url.Content("~/Content/Images/bullet1.gif")" alt="" title="" /></span>@Bk.BookName</div>
<div class="feat_prod_box_details">
    <div class="prod_img">
        <img src="@Url.Content(string.Format("~/Content/Images/Book/{0}.jpg", sImageFile))" alt="" title="" border="0" />
        <br />
        <br />
        <a href="@Url.Content(string.Format("~/Content/Images/Book/{0}.jpg", sImageFile))" rel="lightbox">
            <img src="@Url.Content("~/Content/Images/zoom.gif")" alt="" title="" border="0" /></a>
    </div>
    <div class="prod_det_box">
        <div class="box_top">
        </div>
        <div class="box_center">
            <div class="prod_title">
                Details</div>
            <p class="details">
                @Bk.Description
            </p>
            <div class="price">
                <strong>PRICE:</strong> <span class="red">@Bk.Price $</span></div>
            @using (Html.BeginForm("Add", "ShoppingCart", new { ItemID = Bk.ID }))
            {
                <div class="price">
                    Qty @Html.TextBox("Qty", "1", new { style = "width:50px" })
                </div>
                <a href="javascript:$('form').submit();" class="more">
                    <img src="@Url.Content("~/Content/Images/order_now.gif")" alt="" title="" border="0" />
                </a>
                <div class="clear">
                </div>
            }
        </div>
        <div class="box_bottom">
        </div>
    </div>
    <div class="clear">
    </div>
</div>
<div class="clear">
</div>
